//
//  HWHttpManager.swift
//  HWPromoteProjectAPP
//
//  Created by 王昌健 on 2022/2/8.
//  Copyright © 2022 王昌健. All rights reserved.
//

import UIKit
import Alamofire
class HWHttpManager: NSObject {
    var uid = HWLocallyStoredData.getLoginUserID()
    var tStr = WMUtil.getTimeSp()
    var p = 1
    var max_p = "1"
}

extension HWHttpManager {
    /// sign加密
    /// - Returns: sign
    func encrySign() -> String {
        
        let sign = "\(uid)\(tStr)\("adesxloksy13s98adv")"
        let signMD5 = WMUtil.md5HexDigest(sign) ?? ""
        return signMD5
    }
}

extension HWHttpManager {
    /// 首页
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getHomeInfo(success:@escaping (_ infoModel:HWHomeModel) -> Void, failure:@escaping(_ error:String)->Void){
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_Home)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = HWHomeModel.deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model)
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
                failure("获取数据失败")
            }
        }
    }
    
    /// 我的
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getMineInfo(success:@escaping (_ infoModel:HWMineModel) -> Void, failure:@escaping(_ error:String)->Void){
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_Mine)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = HWMineModel.deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model)
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 开服信息
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getOpenServiceInfo(success:@escaping (_ infoModel:[HWOpenServiceModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_OpenService)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWOpenServiceModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWOpenServiceModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 开服信息加载更多
    func getOpenServiceInfoFooter(success:@escaping (_ :[HWOpenServiceModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
        ] as [String : Any]
        
        AF.request(URL(string: URL_OpenService)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWOpenServiceModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWOpenServiceModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 推广信息
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getAssetsInfo(success:@escaping (_ infoModel:HWAssetsModel) -> Void, failure:@escaping(_ error:String)->Void){
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_Assets)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = HWAssetsModel.deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model)
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 收入明细
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getIncomeDetailsInfo(success:@escaping (_ infoModel:[HWAssetsIncomeDetailModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_IncomeDetails)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWAssetsIncomeDetailModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWAssetsIncomeDetailModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 收入明细加载更多
    func getIncomeDetailsInfoFooter(success:@escaping (_ :[HWAssetsIncomeDetailModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
        ] as [String : Any]
        
        AF.request(URL(string: URL_IncomeDetails)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWAssetsIncomeDetailModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWAssetsIncomeDetailModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 推广游戏分类
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getGameCategoryInfo(success:@escaping (_ infoModel:[HWGameCategoryModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_GameCategory)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWGameCategoryModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWGameCategoryModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 推广游戏
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getPromoteGamesInfo(keyword:String,type:String,success:@escaping (_ infoModel:[HWPromoteGameModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "keyword":keyword,
            "type":type
        ] as [String : Any]
        
        AF.request(URL(string: URL_PromoteGames)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWPromoteGameModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWPromoteGameModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 推广游戏加载更多
    func getPromoteGamesInfoFooter(keyword:String,type:String,success:@escaping (_ :[HWPromoteGameModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
            "keyword":keyword,
            "type":type
        ] as [String : Any]
        
        AF.request(URL(string: URL_PromoteGames)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWPromoteGameModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWPromoteGameModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 游戏礼包
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getGameGiftBagInfo(keyword:String,success:@escaping (_ infoModel:[HWGameGiftBagModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
            "keyword":keyword
        ] as [String : Any]
        
        AF.request(URL(string: URL_GameBag)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? String == "1" {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWGameGiftBagModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWGameGiftBagModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 游戏礼包加载更多
    func getGameGiftBagInfoFooter(keyword:String,success:@escaping (_ :[HWGameGiftBagModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
            "keyword":keyword
        ] as [String : Any]
        
        AF.request(URL(string: URL_GameBag)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWGameGiftBagModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWGameGiftBagModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 人气榜
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getPopularityListInfo(success:@escaping (_ infoModel:[HWRankListModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_RankList)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWRankListModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWRankListModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 人气榜加载更多
    func getPopularityListInfoFooter(success:@escaping (_ :[HWRankListModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
        ] as [String : Any]
        
        AF.request(URL(string: URL_RankList)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWRankListModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWRankListModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 消费榜
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getConsumeRankInfo(success:@escaping (_ infoModel:[HWConsumeRankModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_ConsumeList)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWConsumeRankModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWConsumeRankModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 消费榜加载更多
    func getConsumeRankInfoFooter(success:@escaping (_ :[HWConsumeRankModel]) -> Void, failure:@escaping(_ :String)->Void){
        p += 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign(),
            "p":"\(p)",
        ] as [String : Any]
        
        AF.request(URL(string: URL_ConsumeList)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWConsumeRankModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWConsumeRankModel] ?? [])
                        }
                        
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        self.p -= 1
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    self.p -= 1
                    print("没有获取到数据")
                    
                }
                
            }else {
                self.p -= 1
                print("获取数据失败")
            }
        }
    }
    
    /// 注册方式
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getRegistTypeInfo(success:@escaping (_ infoModel:HWRegistTypeModel) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_RegistType)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = HWRegistTypeModel.deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model)
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 充值方式
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getRechargeTypeInfo(success:@escaping (_ infoModel:HWRechargeTypeModel) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_RechargeType)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = HWRechargeTypeModel.deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model)
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
    /// 公告
    /// - Parameters:
    ///   - success: model
    ///   - failure: error
    func getNoticeInfo(success:@escaping (_ infoModel:[HWNoticeModel]) -> Void, failure:@escaping(_ error:String)->Void){
        p = 1
        tStr = WMUtil.getTimeSp()
        uid = HWLocallyStoredData.getLoginUserID()
        let parameters  = [
            "uid":uid,
            "t":tStr,
            "sign":encrySign()
        ] as [String : Any]
        
        AF.request(URL(string: URL_Notice)!, method: .post, parameters: parameters).responseString { (responses) in
            if responses.value != nil {
                
                let result:String = responses.value ?? ""
                if result != "" {
                    
                    let resultDic = HWUniversal.JSONStringToDictionary(jsonString: result)
                    if resultDic["code"] as? Int == 1 {
                        
                        
                        print("***********\(HWUniversal.JSONStringToDictionary(jsonString: result))")
                        if let model = [HWNoticeModel].deserialize(from: result ,designatedPath: ".data") {
                            print(model)
                            success(model as? [HWNoticeModel] ?? [])
                            
                        }
                        
                    } else if resultDic["code"] as? Int == 100 {
                        //                        self.reLogin(message: (resultDic["message"] as? String) ?? "")
                    }else {
                        
                        print("请求失败--原因:\(resultDic["message"] ?? "请求失败--未知原因")")
                        failure(resultDic["message"] as? String ?? "")
                    }
                    
                }else {
                    print("没有获取到数据")
                }
            }else {
                print("获取数据失败")
            }
        }
    }
    
}
